#install_github(“jokergoo/ComplexHeatmap”) Didn’t install #didn’t install BiocManager::install(“inveRsion”)
library(devtools)
## Loading required package: usethis
library(bigstatsr)
library(bigsnpr)
library(ggplot2)
library(OutFLANK)
## Loading required package: qvalue
library(vegan)
## Loading required package: permute
##
## Attaching package: 'permute'
## The following object is masked from 'package:devtools':
##
## check
## Loading required package: lattice
## This is vegan 2.6-6.1
library(pheatmap)
sessionInfo()
## R version 4.4.0 (2024-04-24)
## Platform: x86_64-apple-darwin20
## Running under: macOS Sonoma 14.5
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
##
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
##
## time zone: America/New_York
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] pheatmap_1.0.12 vegan_2.6-6.1 lattice_0.22-6 permute_0.9-7
## [5] OutFLANK_0.2 qvalue_2.36.0 ggplot2_3.5.1 bigsnpr_1.12.2
## [9] bigstatsr_1.5.12 devtools_2.4.5 usethis_2.2.3
##
## loaded via a namespace (and not attached):
## [1] gtable_0.3.5 xfun_0.44 bslib_0.7.0 htmlwidgets_1.6.4
## [5] remotes_2.5.0 bigassertr_0.1.6 vctrs_0.6.5 tools_4.4.0
## [9] generics_0.1.3 parallel_4.4.0 tibble_3.2.1 fansi_1.0.6
## [13] cluster_2.1.6 pkgconfig_2.0.3 Matrix_1.7-0 data.table_1.15.4
## [17] RColorBrewer_1.1-3 rngtools_1.5.2 lifecycle_1.0.4 compiler_4.4.0
## [21] stringr_1.5.1 munsell_0.5.1 bigparallelr_0.3.2 codetools_0.2-20
## [25] httpuv_1.6.15 htmltools_0.5.8.1 sass_0.4.9 yaml_2.3.8
## [29] later_1.3.2 pillar_1.9.0 jquerylib_0.1.4 urlchecker_1.0.1
## [33] MASS_7.3-60.2 ellipsis_0.3.2 cachem_1.1.0 doRNG_1.8.6
## [37] sessioninfo_1.2.2 iterators_1.0.14 foreach_1.5.2 nlme_3.1-164
## [41] mime_0.12 tidyselect_1.2.1 digest_0.6.35 stringi_1.8.4
## [45] reshape2_1.4.4 dplyr_1.1.4 purrr_1.0.2 splines_4.4.0
## [49] cowplot_1.1.3 fastmap_1.2.0 grid_4.4.0 colorspace_2.1-0
## [53] cli_3.6.2 magrittr_2.0.3 pkgbuild_1.4.4 utf8_1.2.4
## [57] withr_3.0.0 scales_1.3.0 promises_1.3.0 rmarkdown_2.27
## [61] bigsparser_0.6.1 memoise_2.0.1 shiny_1.8.1.1 evaluate_0.23
## [65] knitr_1.46 doParallel_1.0.17 miniUI_0.1.1.1 mgcv_1.9-1
## [69] profvis_0.3.8 rlang_1.1.3 Rcpp_1.0.12 xtable_1.8-4
## [73] glue_1.7.0 pkgload_1.3.4 rstudioapi_0.16.0 jsonlite_1.8.8
## [77] plyr_1.8.9 R6_2.5.1 fs_1.6.4 flock_0.7
datadir <- "/Users/lotterhos/Library/CloudStorage/GoogleDrive-k.lotterhos@gmail.com/.shortcut-targets-by-id/1DPJy8RgFslz3_PSZLLl7Z21mCvQUvnJZ/Manuscripts/Cod Ecotypes GoM /data/"
bigSNP <- snp_attach(paste0(datadir, "acod_merged.MAF05_QC.rds"))
# drop the individual at the 17th position because it is a duplicate.
#It was a fish that was right in the middle of being red or olive and
#it accidentally got left in both groups and got sequenced twice.
G_full <- bigSNP$genotypes[-17,]
pos_full <- bigSNP$map$physical.pos
samp_full <- bigSNP$fam$sample.ID[-17]
pop_full <- bigSNP$fam$family.ID[-17]
chrom_full <- bigSNP$map$chromosome
unique(chrom_full)
## [1] "NC_044048.1" "NC_044049.1" "NC_044050.1" "NC_044051.1" "NC_044052.1"
## [6] "NC_044053.1" "NC_044054.1" "NC_044055.1" "NC_044056.1" "NC_044057.1"
## [11] "NC_044058.1" "NC_044059.1" "NC_044060.1" "NC_044061.1" "NC_044062.1"
## [16] "NC_044063.1" "NC_044064.1" "NC_044065.1" "NC_044066.1" "NC_044067.1"
## [21] "NC_044068.1" "NC_044069.1" "NC_044070.1"
dim(G_full)
## [1] 294 2094293
NCORES <- nb_cores()
head(bigSNP$fam)
## family.ID sample.ID paternal.ID maternal.ID sex affection
## 1 Pop1 16216 0 0 0 -9
## 2 Pop1 16220 0 0 0 -9
## 3 Pop1 16224 0 0 0 -9
## 4 Pop1 16225 0 0 0 -9
## 5 Pop1 16229 0 0 0 -9
## 6 Pop1 16231 0 0 0 -9
head(samp_full)
## [1] 16216 16220 16224 16225 16229 16231
pop.names <- paste0("Pop", 1:9)
pop.IDs<- c("GoM.Mass.Olive.Winter",
"GoM.Mass.Red",
"GoM.Mass.Olive.Unknown",
"GoM.Cashes.Olive",
"GoM.Cashes.Red",
"Ice.Off.SW",
"Ice.Near.SW",
"Ice.Off.NE",
"Ice.Near.NE")
pop.IDs2 <- c("GoM Nearshore Olive - Winter Spawner",
"GoM Nearshore Red",
"GoM Nearshore Olive",
"GoM Nearshore Olive",
"GoM Nearshore Red",
"Iceland Offshore",
"Iceland Nearshore",
"Iceland Offshore",
"Iceland Nearshore")
region <- c(rep("GoM", 5), rep("Iceland", 4))
ecotype <- c(rep("Nearshore",5), "Offshore", "Nearshore",
"Offshore", "Nearshore")
pop.colors <- c(adjustcolor("darkgreen",1), #mass winter
adjustcolor("salmon",1), #mass red
adjustcolor("goldenrod3",0.5), #mass unknown
adjustcolor("darkgreen",0.75), #cashes olive
adjustcolor("salmon",0.75), #cashes red
adjustcolor("darkviolet",1), # Iceland SW Off
adjustcolor("cornflowerblue",0.5), #Iceland SW Near
adjustcolor("darkviolet",0.5), #Iceland NE Off
adjustcolor("cornflowerblue",1) #Iceland NE Near
)
pop2.colors <- c(adjustcolor("darkgreen",1), #mass winter
adjustcolor("salmon",1), #mass red
adjustcolor("darkgreen",0.5), #mass unknown
adjustcolor("darkgreen",0.5), #cashes olive
adjustcolor("salmon",1), #cashes red
adjustcolor("darkviolet",0.75), # Iceland SW Off
adjustcolor("cornflowerblue",1), #Iceland SW Near
adjustcolor("darkviolet",0.75), #Iceland NE Off
adjustcolor("cornflowerblue",1) #Iceland NE Near
)
write.table(data.frame(pop.names,pop.IDs, pop.colors, region, ecotype, pop.IDs2, pop2.colors), "../outputs/1-Pops.txt", row.names=FALSE)
write("This file contains population-level information
pop.names: Numbered population ID corresponding to some files
pop.IDs: Specific Geographic Location
pop.colors: Color corresponding to pop.IDs
region: Iceland or GoM
ecotype: Nearshore or Offshore
pop.IDs2: An ID based on ecotype and geographic region
pop2.colors: Color corresponding to pop.IDs2
",
"../outputs/1-Pops.txt.metadata.md")
samp_full <- data.frame(samp_full)
#Remove sample 17, duplicate
samp_full$Pop <- as.factor(bigSNP$fam$family.ID[-17])
# Add population name to smaple dataframe
samp_full$PopID <- factor(samp_full$Pop, ordered=TRUE)
levels(samp_full$PopID) = pop.IDs # this works because the
# populations are numbered
head(samp_full)
## samp_full Pop PopID
## 1 16216 Pop1 GoM.Mass.Olive.Winter
## 2 16220 Pop1 GoM.Mass.Olive.Winter
## 3 16224 Pop1 GoM.Mass.Olive.Winter
## 4 16225 Pop1 GoM.Mass.Olive.Winter
## 5 16229 Pop1 GoM.Mass.Olive.Winter
## 6 16231 Pop1 GoM.Mass.Olive.Winter
levels(samp_full$PopID)
## [1] "GoM.Mass.Olive.Winter" "GoM.Mass.Red" "GoM.Mass.Olive.Unknown"
## [4] "GoM.Cashes.Olive" "GoM.Cashes.Red" "Ice.Off.SW"
## [7] "Ice.Near.SW" "Ice.Off.NE" "Ice.Near.NE"
samp_full$Region <- "GoM"
samp_full$Region[samp_full$Pop %in% c("Pop6", "Pop7",
"Pop8", "Pop9")] = "Iceland"
samp_full$Ecotype <- "1-Nearshore"
samp_full$Ecotype[samp_full$Pop %in% c("Pop6", "Pop8")] <- "2-Offshore"
samp_full$Region <- as.factor(samp_full$Region)
samp_full$Ecotype <- as.factor(samp_full$Ecotype)
head(samp_full)
## samp_full Pop PopID Region Ecotype
## 1 16216 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 2 16220 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 3 16224 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 4 16225 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 5 16229 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 6 16231 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
tail(samp_full)
## samp_full Pop PopID Region Ecotype
## 289 18096 Pop9 Ice.Near.NE Iceland 1-Nearshore
## 290 18097 Pop9 Ice.Near.NE Iceland 1-Nearshore
## 291 18098 Pop9 Ice.Near.NE Iceland 1-Nearshore
## 292 18099 Pop9 Ice.Near.NE Iceland 1-Nearshore
## 293 18100 Pop9 Ice.Near.NE Iceland 1-Nearshore
## 294 18101 Pop9 Ice.Near.NE Iceland 1-Nearshore
samp_full$label <- paste(samp_full$Region,samp_full$Ecotype, samp_full$PopID, samp_full$samp_full, sep="_")
### colors for Region and Ecotype ####
samp_full$Region_color <- as.factor(samp_full$Region)
levels(samp_full$Region_color) <- c("blue4", "darkgoldenrod")
samp_full$Region_color <- as.character(samp_full$Region_color) # convert factor back to character
samp_full$Ecotype_color <- as.factor(samp_full$Ecotype)
levels(samp_full$Ecotype_color) <- c("darkcyan", "seagreen2")
samp_full$Ecotype_color <- as.character(samp_full$Ecotype_color) # convert factor back to character
### colors for populations ####
samp_full$PopID_color <- as.factor(samp_full$Pop)
levels(samp_full$PopID_color) <- pop.colors # this works because the populations are ordered by number
samp_full$PopID_color <- as.character(samp_full$PopID_color )
muts <- data.frame(chrom_full, pos_full, Glabel = paste(chrom_full,pos_full, sep="__"))
colnames(G_full) <- muts$Glabel
rownames(G_full) <- samp_full$label
set.seed(29435798)
index <- sort(sample(1:length(pos_full), 50000))
Gsub <- G_full[,index]
# Recode for bigsnpr package tools
Gsub_snp <- add_code256(big_copy(Gsub,type="raw"),code=bigsnpr:::CODE_012)
# PCA
# make sure this is run on a code 256 type
# snp object, or it will run forever!
set.seed(6345082)
svd7 <- big_randomSVD(Gsub_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
# Add PC loadings to sample info
samp_full$Gsub_PC1 <- svd7$u[,1]
samp_full$Gsub_PC2 <- svd7$u[,2]
# Add PC loadings to muts
muts$Gsub_PC1 <- muts$Gsub_PC2 <-NA
muts$Gsub_PC1[index] <- svd7$v[,1]
muts$Gsub_PC2[index] <- svd7$v[,2]
#plot(abs(muts$Gsub_PC1), pch=19, col=adjustcolor("blue",0.01))
index <- sort(which(muts$chrom_full=="NC_044048.1"))
Gsub <- G_full[,index]
# Recode for bigsnpr package tools
Gsub_snp <- add_code256(big_copy(Gsub,type="raw"),code=bigsnpr:::CODE_012)
set.seed(62385534)
svd7 <- big_randomSVD(Gsub_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
muts$Gsub_LG1_PC1 <- NA
muts$Gsub_LG1_PC1[index] <- svd7$v[,1]
# Chrom 1
plot(muts$pos_full[muts$chrom_full=="NC_044048.1"],
abs(muts$Gsub_LG1_PC1[muts$chrom_full=="NC_044048.1"]),
pch=19, col=adjustcolor("blue",0.1),
main="LG1", ylab="PC1 loading", xlab="position (bp)")
(maxload1 <- quantile(abs(muts$Gsub_LG1_PC1), probs=0.99, na.rm=TRUE))
## 99%
## 0.006090969
abline(h=maxload1)
#start
LG1start <- min(which(abs(muts$Gsub_LG1_PC1)>maxload1))
LG1end <- max(which(abs(muts$Gsub_LG1_PC1)>maxload1))
muts[LG1start ,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 33090 NC_044048.1 11299038 NC_044048.1__11299038 NA NA 0.006117522
LG1start_minus1MB <- max(which(muts$pos_full<muts$pos_full[LG1start]-1000000 & muts$chrom_full=="NC_044048.1"))
muts[LG1start_minus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 29750 NC_044048.1 10298978 NC_044048.1__10298978 NA NA 0.0002175627
muts[LG1end,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 104012 NC_044048.1 28292263 NC_044048.1__28292263 NA NA
## Gsub_LG1_PC1
## 104012 0.006091121
LG1end_plus1MB <- max(which(muts$pos_full<muts$pos_full[LG1end]+1000000 & muts$chrom_full=="NC_044048.1"))
muts[LG1end_plus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 106154 NC_044048.1 29268531 NC_044048.1__29268531 NA NA
## Gsub_LG1_PC1
## 106154 -0.0005602807
plot(muts$pos_full[LG1start_minus1MB:LG1end_plus1MB],
abs(muts$Gsub_LG1_PC1[LG1start_minus1MB:LG1end_plus1MB]),
pch=19, col=adjustcolor("blue",0.1),
main="LG1", ylab="PC1 loading", xlab="position (bp)")
abline(v=muts$pos_full[LG1start], col="orange", lwd=2)
abline(v=muts$pos_full[LG1end], col="orange", lwd=2)
abline(h=maxload1, col="lightgrey")
index <- sort(which(muts$chrom_full=="NC_044049.1"))
Gsub <- G_full[,index]
# Recode for bigsnpr package tools
Gsub_snp <- add_code256(big_copy(Gsub,type="raw"),code=bigsnpr:::CODE_012)
set.seed(235540968)
svd7 <- big_randomSVD(Gsub_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
muts$Gsub_LG2_PC1 <- NA
muts$Gsub_LG2_PC1[index] <- svd7$v[,1]
# Chrom 2
plot(muts$pos_full[muts$chrom_full=="NC_044049.1"],
abs(muts$Gsub_LG2_PC1[muts$chrom_full=="NC_044049.1"]),
pch=19, col=adjustcolor("blue",0.1),
main="LG2", ylab="PC1 loading", xlab="position (bp)")
(maxload1 <- quantile(abs(muts$Gsub_LG2_PC1), probs=0.99, na.rm=TRUE))
## 99%
## 0.01020831
abline(h=maxload1)
#start
LG2start <- min(which(abs(muts$Gsub_LG2_PC1)>maxload1))
LG2end <- max(which(abs(muts$Gsub_LG2_PC1)>maxload1))
muts[LG2start ,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 111433 NC_044049.1 481246 NC_044049.1__481246 NA NA NA
## Gsub_LG2_PC1
## 111433 0.01027682
LG2start_minus1MB <-min(which(muts$chrom_full=="NC_044049.1"))
# in this case it's just the start of the chromosome
muts[LG2start_minus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 109720 NC_044049.1 884 NC_044049.1__884 NA NA NA
## Gsub_LG2_PC1
## 109720 -0.0006092057
muts[LG2end,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 132871 NC_044049.1 4466546 NC_044049.1__4466546 NA NA NA
## Gsub_LG2_PC1
## 132871 0.01029919
LG2end_plus1MB <- max(which(muts$pos_full<muts$pos_full[LG2end]+1000000 & muts$chrom_full=="NC_044049.1"))
muts[LG2end_plus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 135332 NC_044049.1 5434591 NC_044049.1__5434591 NA NA NA
## Gsub_LG2_PC1
## 135332 0.0002754641
plot(muts$pos_full[LG2start_minus1MB:LG2end_plus1MB],
abs(muts$Gsub_LG2_PC1[LG2start_minus1MB:LG2end_plus1MB]),
pch=19, col=adjustcolor("blue",0.1),
main="LG2", ylab="PC1 loading", xlab="position (bp)")
abline(v=muts$pos_full[LG2start], col="orange", lwd=2)
abline(v=muts$pos_full[LG2end], col="orange", lwd=2)
abline(h=maxload1, col="lightgrey")
index <- sort(which(muts$chrom_full=="NC_044054.1"))
Gsub <- G_full[,index]
# Recode for bigsnpr package tools
Gsub_snp <- add_code256(big_copy(Gsub,type="raw"),code=bigsnpr:::CODE_012)
set.seed(42348064)
svd7 <- big_randomSVD(Gsub_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
muts$Gsub_LG7_PC1 <- NA
muts$Gsub_LG7_PC1[index] <- svd7$v[,1]
# Chrom 7
plot(muts$pos_full[muts$chrom_full=="NC_044054.1"],
abs(muts$Gsub_LG7_PC1[muts$chrom_full=="NC_044054.1"]),
pch=19, col=adjustcolor("blue",0.1),
main="LG7", ylab="PC1 loading", xlab="position (bp)")
(maxload1 <- quantile(abs(muts$Gsub_LG7_PC1), probs=0.99, na.rm=TRUE))
## 99%
## 0.006244065
abline(h=maxload1)
#start
LG7start <- min(which(abs(muts$Gsub_LG7_PC1)>maxload1))
LG7end <- max(which(abs(muts$Gsub_LG7_PC1)>maxload1))
muts[LG7start ,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 648745 NC_044054.1 16828712 NC_044054.1__16828712 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1
## 648745 NA NA -0.006261396
LG7start_minus1MB <-max(which(muts$pos_full<muts$pos_full[LG7start]-1000000 & muts$chrom_full=="NC_044054.1"))
# in this case it's just the start of the chromosome
muts[LG7start_minus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 645345 NC_044054.1 15828590 NC_044054.1__15828590 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1
## 645345 NA NA 0.0002948823
muts[LG7end,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 696592 NC_044054.1 26336501 NC_044054.1__26336501 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1
## 696592 NA NA -0.006245197
LG7end_plus1MB <- max(which(muts$pos_full<muts$pos_full[LG7end]+1000000 & muts$chrom_full=="NC_044054.1"))
muts[LG7end_plus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 700639 NC_044054.1 27336483 NC_044054.1__27336483 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1
## 700639 NA NA -0.000523632
plot(muts$pos_full[LG7start_minus1MB:LG7end_plus1MB],
abs(muts$Gsub_LG7_PC1[LG7start_minus1MB:LG7end_plus1MB]),
pch=19, col=adjustcolor("blue",0.1),
main="LG7", ylab="PC1 loading", xlab="position (bp)")
abline(v=muts$pos_full[LG7start], col="orange", lwd=2)
abline(v=muts$pos_full[LG7end], col="orange", lwd=2)
abline(h=maxload1, col="lightgrey")
index <- sort(which(muts$chrom_full=="NC_044059.1"))
Gsub <- G_full[,index]
# Recode for bigsnpr package tools
Gsub_snp <- add_code256(big_copy(Gsub,type="raw"),code=bigsnpr:::CODE_012)
set.seed(73240982)
svd7 <- big_randomSVD(Gsub_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
muts$Gsub_LG12_PC1 <- NA
muts$Gsub_LG12_PC1[index] <- svd7$v[,1]
# Chrom 12
plot(muts$pos_full[muts$chrom_full=="NC_044059.1"],
abs(muts$Gsub_LG12_PC1[muts$chrom_full=="NC_044059.1"]),
pch=19, col=adjustcolor("blue",0.1),
main="LG12", ylab="PC1 loading", xlab="position (bp)")
(maxload1 <- quantile(abs(muts$Gsub_LG12_PC1), probs=0.99, na.rm=TRUE))
## 99%
## 0.008958482
abline(h=maxload1)
#start
LG12start <- min(which(abs(muts$Gsub_LG12_PC1)>maxload1))
LG12end <- max(which(abs(muts$Gsub_LG12_PC1)>maxload1))
muts[LG12start ,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 1098771 NC_044059.1 1809214 NC_044059.1__1809214 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1 Gsub_LG12_PC1
## 1098771 NA NA NA -0.008967974
LG12start_minus1MB <-max(which(muts$pos_full<muts$pos_full[LG12start]-1000000 & muts$chrom_full=="NC_044059.1"))
# in this case it's just the start of the chromosome
muts[LG12start_minus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1 Gsub_LG1_PC1
## 1096496 NC_044059.1 721009 NC_044059.1__721009 NA NA NA
## Gsub_LG2_PC1 Gsub_LG7_PC1 Gsub_LG12_PC1
## 1096496 NA NA -0.004226609
muts[LG12end,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 1141346 NC_044059.1 13690550 NC_044059.1__13690550 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1 Gsub_LG12_PC1
## 1141346 NA NA NA -0.009079696
LG12end_plus1MB <- max(which(muts$pos_full<muts$pos_full[LG12end]+1000000 & muts$chrom_full=="NC_044059.1"))
muts[LG12end_plus1MB,]
## chrom_full pos_full Glabel Gsub_PC2 Gsub_PC1
## 1142816 NC_044059.1 14677663 NC_044059.1__14677663 NA NA
## Gsub_LG1_PC1 Gsub_LG2_PC1 Gsub_LG7_PC1 Gsub_LG12_PC1
## 1142816 NA NA NA 2.969367e-05
plot(muts$pos_full[LG12start_minus1MB:LG12end_plus1MB],
abs(muts$Gsub_LG12_PC1[LG12start_minus1MB:LG12end_plus1MB]),
pch=19, col=adjustcolor("blue",0.1),
main="LG12", ylab="PC1 loading", xlab="position (bp)")
abline(v=muts$pos_full[LG12start], col="orange", lwd=2)
abline(v=muts$pos_full[LG12end], col="orange", lwd=2)
abline(h=maxload1, col="lightgrey")
breakpoints <- data.frame(
LG = c("LG1","LG2", "LG7","LG12"),
LGstartIndex = c(LG1start,LG2start,LG7start,LG12start),
LGendIndex = c(LG1end,LG2end,LG7end,LG12end),
chrom=chrom_full[c(LG1start,LG2start,LG7start,LG12start)],
LGstartPos = pos_full[c(LG1start,LG2start,LG7start,LG12start)],
LGendPos = pos_full[c(LG1end,LG2end,LG7end,LG12end)],
LGstartPos_minus1MB_index = c(LG1start_minus1MB,
LG2start_minus1MB,
LG7start_minus1MB,
LG12start_minus1MB),
LGendPos_plus1MB_index =c(LG1end_plus1MB,
LG2end_plus1MB,
LG7end_plus1MB,
LG12end_plus1MB)
)
samp_full$Ecotype2 <- factor(paste0(samp_full$Ecotype,"-",
samp_full$Region), ordered=TRUE)
levels(samp_full$Ecotype2)
## [1] "1-Nearshore-GoM" "1-Nearshore-Iceland" "2-Offshore-Iceland"
samp_full$Ecotype2_color <- samp_full$Ecotype2
levels(samp_full$Ecotype2_color) <- c("lightblue","cornflowerblue","darkviolet")
levels(samp_full$Ecotype2_color)
## [1] "lightblue" "cornflowerblue" "darkviolet"
str(samp_full$Ecotype2_color)
## Ord.factor w/ 3 levels "lightblue"<"cornflowerblue"<..: 1 1 1 1 1 1 1 1 1 1 ...
LGind <- c(LG1start:LG1end, LG2start:LG2end,
LG7start:LG7end, LG12start:LG12end)
G_LG <- G_full[,LGind]
dim(G_full)
## [1] 294 2094293
G_nonInv <- G_full[,-LGind]
dim(G_nonInv)
## [1] 294 1911507
set.seed(34594323)
G_nonInv_subset <- G_nonInv[,sample(1:ncol(G_nonInv), 100000,
replace=FALSE)]
dim(G_nonInv_subset)
## [1] 294 100000
saveRDS(G_nonInv_subset, file="../outputs/G_nonInv_subset.RDS")
write("This file contains a genotype matrix with 100000 SNPs randomly sampled from non-inversion regions, output from file KL-1 inversion code all.Rmd. The samples are in rows and the SNPs are in columns. Each cell stores the number of copies of the alternate allele.",
"../outputs/G_nonInv_subset.metadata")
head(colnames(G_LG))
## [1] "NC_044048.1__11299038" "NC_044048.1__11299525" "NC_044048.1__11299592"
## [4] "NC_044048.1__11299650" "NC_044048.1__11302157" "NC_044048.1__11302179"
head(rownames(G_LG))
## [1] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216"
## [2] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220"
## [3] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224"
## [4] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225"
## [5] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229"
## [6] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231"
dim(G_LG)
## [1] 294 182786
# Recode for bigsnpr package tools
G_LG_snp <- add_code256(big_copy(G_LG,type="raw"),code=bigsnpr:::CODE_012)
# PCA
# make sure this is run on a code 256 type
# snp object, or it will run forever!
set.seed(3459723)
svd7 <- big_randomSVD(G_LG_snp,
snp_scaleBinom(),
ncores = NCORES,
k=2)
samp_full$G_AllInv_PC1 <- svd7$u[,1]
samp_full$G_AllInv_PC2 <- svd7$u[,2]
str(samp_full)
## 'data.frame': 294 obs. of 15 variables:
## $ samp_full : int 16216 16220 16224 16225 16229 16231 16232 16233 16234 16236 ...
## $ Pop : Factor w/ 9 levels "Pop1","Pop2",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ PopID : Ord.factor w/ 9 levels "GoM.Mass.Olive.Winter"<..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Region : Factor w/ 2 levels "GoM","Iceland": 1 1 1 1 1 1 1 1 1 1 ...
## $ Ecotype : Factor w/ 2 levels "1-Nearshore",..: 1 1 1 1 1 1 1 1 1 1 ...
## $ label : chr "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225" ...
## $ Region_color : chr "blue4" "blue4" "blue4" "blue4" ...
## $ Ecotype_color : chr "darkcyan" "darkcyan" "darkcyan" "darkcyan" ...
## $ PopID_color : chr "#006400FF" "#006400FF" "#006400FF" "#006400FF" ...
## $ Gsub_PC1 : num -0.0589 -0.067 -0.0651 -0.0614 -0.0538 ...
## $ Gsub_PC2 : num 0.02733 0.00134 0.00245 0.00487 0.0154 ...
## $ Ecotype2 : Ord.factor w/ 3 levels "1-Nearshore-GoM"<..: 1 1 1 1 1 1 1 1 1 1 ...
## $ Ecotype2_color: Ord.factor w/ 3 levels "lightblue"<"cornflowerblue"<..: 1 1 1 1 1 1 1 1 1 1 ...
## $ G_AllInv_PC1 : num 0.0353 0.065 0.0613 0.0515 0.0319 ...
## $ G_AllInv_PC2 : num -0.00791 -0.04903 -0.05377 -0.03753 0.01956 ...
pdf("../figures/PCA-samples-inversion-SNPs-only.pdf", width=6, height=6)
ggplot(samp_full) + geom_point(aes(x=G_AllInv_PC1,
y=G_AllInv_PC2,
colour = PopID,
shape= Ecotype,
pch=Ecotype,
size=Ecotype)) +
scale_colour_manual(values=pop.colors) +
xlab("Sample loadings PC1 - inversion SNPs only") +
ylab("Sample loadings PC2 - inversion SNPs only") +
theme_classic()
## Warning: Duplicated aesthetics after name standardisation: shape
## Warning: Using size for a discrete variable is not advised.
## Warning: Duplicated aesthetics after name standardisation: shape
dev.off()
## quartz_off_screen
## 2
dist <- dist(G_LG, diag=TRUE)
str(dist)
## 'dist' num [1:43071] 297 281 298 287 256 ...
## - attr(*, "Size")= int 294
## - attr(*, "Labels")= chr [1:294] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225" ...
## - attr(*, "Diag")= logi TRUE
## - attr(*, "Upper")= logi FALSE
## - attr(*, "method")= chr "euclidean"
## - attr(*, "call")= language dist(x = G_LG, diag = TRUE)
hc <- hclust(dist)
str(hc)
## List of 7
## $ merge : int [1:293, 1:2] -21 -8 -54 -223 -193 -218 -151 -138 7 -166 ...
## $ height : num [1:293] 104 110 119 196 198 ...
## $ order : int [1:294] 146 258 230 147 172 238 243 142 164 156 ...
## $ labels : chr [1:294] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225" ...
## $ method : chr "complete"
## $ call : language hclust(d = dist)
## $ dist.method: chr "euclidean"
## - attr(*, "class")= chr "hclust"
dhc <- as.dendrogram(hc)
cut_avg <- cutree(hc, k = 5)
str(cut_avg)
## Named int [1:294] 1 1 2 1 1 1 1 1 1 1 ...
## - attr(*, "names")= chr [1:294] "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224" "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225" ...
str(dhc)
## --[dendrogram w/ 2 branches and 294 members at h = 554]
## |--[dendrogram w/ 2 branches and 97 members at h = 375]
## | |--[dendrogram w/ 2 branches and 54 members at h = 275]
## | | |--[dendrogram w/ 2 branches and 6 members at h = 219]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18014"
## | | | `--[dendrogram w/ 2 branches and 5 members at h = 215]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18058"
## | | | `--[dendrogram w/ 2 branches and 4 members at h = 211]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18122"
## | | | `--[dendrogram w/ 2 branches and 3 members at h = 209]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18015"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 206]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18047"
## | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18131"
## | | `--[dendrogram w/ 2 branches and 48 members at h = 234]
## | | |--[dendrogram w/ 2 branches and 10 members at h = 214]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18138"
## | | | `--[dendrogram w/ 2 branches and 9 members at h = 213]
## | | | |--[dendrogram w/ 2 branches and 4 members at h = 210]
## | | | | |--[dendrogram w/ 2 branches and 2 members at h = 208]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18008"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18038"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 208]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18029"
## | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18118"
## | | | `--[dendrogram w/ 2 branches and 5 members at h = 211]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18010"
## | | | `--[dendrogram w/ 2 branches and 4 members at h = 209]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18044"
## | | | `--[dendrogram w/ 2 branches and 3 members at h = 207]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18030"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 204]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18109"
## | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18124"
## | | `--[dendrogram w/ 2 branches and 38 members at h = 219]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18140"
## | | `--[dendrogram w/ 2 branches and 37 members at h = 217]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18147"
## | | `--[dendrogram w/ 2 branches and 36 members at h = 213]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18146"
## | | `--[dendrogram w/ 2 branches and 35 members at h = 212]
## | | |--[dendrogram w/ 2 branches and 32 members at h = 211]
## | | | |--[dendrogram w/ 2 branches and 30 members at h = 209]
## | | | | |--[dendrogram w/ 2 branches and 2 members at h = 207]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18001"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18049"
## | | | | `--[dendrogram w/ 2 branches and 28 members at h = 209]
## | | | | |--[dendrogram w/ 2 branches and 19 members at h = 207]
## | | | | | |--[dendrogram w/ 2 branches and 12 members at h = 206]
## | | | | | | |--[dendrogram w/ 2 branches and 8 members at h = 203]
## | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18003"
## | | | | | | | `--[dendrogram w/ 2 branches and 7 members at h = 202]
## | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18141"
## | | | | | | | `--[dendrogram w/ 2 branches and 6 members at h = 201]
## | | | | | | | |--[dendrogram w/ 2 branches and 4 members at h = 199]
## | | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18021"
## | | | | | | | | `--[dendrogram w/ 2 branches and 3 members at h = 198]
## | | | | | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18170"
## | | | | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 196]
## | | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18113"
## | | | | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18128"
## | | | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 200]
## | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18002"
## | | | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18046"
## | | | | | | `--[dendrogram w/ 2 branches and 4 members at h = 204]
## | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18013"
## | | | | | | `--[dendrogram w/ 2 branches and 3 members at h = 203]
## | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18031"
## | | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 199]
## | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18106"
## | | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18133"
## | | | | | `--[dendrogram w/ 2 branches and 7 members at h = 206]
## | | | | | |--[dendrogram w/ 2 branches and 5 members at h = 204]
## | | | | | | |--[dendrogram w/ 2 branches and 2 members at h = 202]
## | | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18026"
## | | | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18130"
## | | | | | | `--[dendrogram w/ 2 branches and 3 members at h = 203]
## | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18025"
## | | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 201]
## | | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18040"
## | | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18125"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 205]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18034"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18149"
## | | | | `--[dendrogram w/ 2 branches and 9 members at h = 208]
## | | | | |--[dendrogram w/ 2 branches and 3 members at h = 206]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18103"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 203]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18104"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18112"
## | | | | `--[dendrogram w/ 2 branches and 6 members at h = 206]
## | | | | |--[dendrogram w/ 2 branches and 3 members at h = 205]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18126"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 203]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18108"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18151"
## | | | | `--[dendrogram w/ 2 branches and 3 members at h = 206]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18143"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 204]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18033"
## | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18039"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 210]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18012"
## | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18150"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 211]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18051"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 208]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18123"
## | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18139"
## | `--[dendrogram w/ 2 branches and 43 members at h = 344]
## | |--[dendrogram w/ 2 branches and 28 members at h = 299]
## | | |--[dendrogram w/ 2 branches and 4 members at h = 249]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18152"
## | | | `--[dendrogram w/ 2 branches and 3 members at h = 243]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18119"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 229]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18117"
## | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18148"
## | | `--[dendrogram w/ 2 branches and 24 members at h = 269]
## | | |--[dendrogram w/ 2 branches and 21 members at h = 236]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18127"
## | | | `--[dendrogram w/ 2 branches and 20 members at h = 232]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18142"
## | | | `--[dendrogram w/ 2 branches and 19 members at h = 229]
## | | | |--[dendrogram w/ 2 branches and 17 members at h = 226]
## | | | | |--[dendrogram w/ 2 branches and 3 members at h = 225]
## | | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18075"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 223]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18017"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18032"
## | | | | `--[dendrogram w/ 2 branches and 14 members at h = 225]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18037"
## | | | | `--[dendrogram w/ 2 branches and 13 members at h = 224]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18019"
## | | | | `--[dendrogram w/ 2 branches and 12 members at h = 221]
## | | | | |--[dendrogram w/ 2 branches and 7 members at h = 220]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18048"
## | | | | | `--[dendrogram w/ 2 branches and 6 members at h = 219]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18024"
## | | | | | `--[dendrogram w/ 2 branches and 5 members at h = 217]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18132"
## | | | | | `--[dendrogram w/ 2 branches and 4 members at h = 216]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18006"
## | | | | | `--[dendrogram w/ 2 branches and 3 members at h = 214]
## | | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18093"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 211]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18041"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18115"
## | | | | `--[dendrogram w/ 2 branches and 5 members at h = 221]
## | | | | |--[dendrogram w/ 2 branches and 3 members at h = 217]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18022"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 215]
## | | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18005"
## | | | | | `--leaf "Iceland_2-Offshore_Ice.Off.SW_18043"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 218]
## | | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18020"
## | | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18081"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 227]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18116"
## | | | `--leaf "Iceland_2-Offshore_Ice.Off.NE_18120"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 242]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18186"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 228]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18136"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18083"
## | `--[dendrogram w/ 2 branches and 15 members at h = 313]
## | |--[dendrogram w/ 2 branches and 3 members at h = 246]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18187"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 226]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18160"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18078"
## | `--[dendrogram w/ 2 branches and 12 members at h = 247]
## | |--[dendrogram w/ 2 branches and 3 members at h = 223]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18052"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 218]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18059"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18091"
## | `--[dendrogram w/ 2 branches and 9 members at h = 233]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18099"
## | `--[dendrogram w/ 2 branches and 8 members at h = 232]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18082"
## | `--[dendrogram w/ 2 branches and 7 members at h = 230]
## | |--[dendrogram w/ 2 branches and 5 members at h = 225]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18110"
## | | `--[dendrogram w/ 2 branches and 4 members at h = 223]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18100"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 220]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18096"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 219]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18193"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18088"
## | `--[dendrogram w/ 2 branches and 2 members at h = 227]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18159"
## | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18162"
## `--[dendrogram w/ 2 branches and 197 members at h = 466]
## |--[dendrogram w/ 2 branches and 21 members at h = 363]
## | |--[dendrogram w/ 2 branches and 4 members at h = 307]
## | | |--[dendrogram w/ 2 branches and 2 members at h = 237]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17016"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17283"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 252]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17285"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17008"
## | `--[dendrogram w/ 2 branches and 17 members at h = 332]
## | |--[dendrogram w/ 2 branches and 3 members at h = 262]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18056"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 240]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18155"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18061"
## | `--[dendrogram w/ 2 branches and 14 members at h = 306]
## | |--[dendrogram w/ 2 branches and 5 members at h = 257]
## | | |--[dendrogram w/ 2 branches and 2 members at h = 229]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18070"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18094"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 234]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18180"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 229]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18188"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18086"
## | `--[dendrogram w/ 2 branches and 9 members at h = 278]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16241"
## | `--[dendrogram w/ 2 branches and 8 members at h = 252]
## | |--[dendrogram w/ 2 branches and 5 members at h = 232]
## | | |--[dendrogram w/ 2 branches and 3 members at h = 229]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18084"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 228]
## | | | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18042"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18185"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 231]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18154"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18175"
## | `--[dendrogram w/ 2 branches and 3 members at h = 233]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18179"
## | `--[dendrogram w/ 2 branches and 2 members at h = 230]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18161"
## | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18090"
## `--[dendrogram w/ 2 branches and 176 members at h = 401]
## |--[dendrogram w/ 2 branches and 99 members at h = 368]
## | |--[dendrogram w/ 2 branches and 10 members at h = 299]
## | | |--[dendrogram w/ 2 branches and 4 members at h = 250]
## | | | |--[dendrogram w/ 2 branches and 2 members at h = 228]
## | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18189"
## | | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18077"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 230]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18171"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18065"
## | | `--[dendrogram w/ 2 branches and 6 members at h = 270]
## | | |--[dendrogram w/ 2 branches and 3 members at h = 234]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18062"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 225]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18173"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18190"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 241]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18164"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 219]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18194"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18092"
## | `--[dendrogram w/ 2 branches and 89 members at h = 358]
## | |--[dendrogram w/ 2 branches and 40 members at h = 302]
## | | |--[dendrogram w/ 2 branches and 22 members at h = 254]
## | | | |--[dendrogram w/ 2 branches and 8 members at h = 249]
## | | | | |--[dendrogram w/ 2 branches and 2 members at h = 246]
## | | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17311"
## | | | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_16211"
## | | | | `--[dendrogram w/ 2 branches and 6 members at h = 247]
## | | | | |--[dendrogram w/ 2 branches and 3 members at h = 244]
## | | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16227"
## | | | | | `--[dendrogram w/ 2 branches and 2 members at h = 241]
## | | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16248"
## | | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17240"
## | | | | `--[dendrogram w/ 2 branches and 3 members at h = 244]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17273"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 239]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17324"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17288"
## | | | `--[dendrogram w/ 2 branches and 14 members at h = 251]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220"
## | | | `--[dendrogram w/ 2 branches and 13 members at h = 249]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17028"
## | | | `--[dendrogram w/ 2 branches and 12 members at h = 247]
## | | | |--[dendrogram w/ 2 branches and 3 members at h = 242]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16238"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 237]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16240"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17292"
## | | | `--[dendrogram w/ 2 branches and 9 members at h = 244]
## | | | |--[dendrogram w/ 2 branches and 4 members at h = 239]
## | | | | |--[dendrogram w/ 2 branches and 2 members at h = 236]
## | | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17010"
## | | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17265"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 236]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17210"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17226"
## | | | `--[dendrogram w/ 2 branches and 5 members at h = 242]
## | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17248"
## | | | `--[dendrogram w/ 2 branches and 4 members at h = 239]
## | | | |--[dendrogram w/ 2 branches and 2 members at h = 235]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17253"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17258"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 237]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17002"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17245"
## | | `--[dendrogram w/ 2 branches and 18 members at h = 259]
## | | |--[dendrogram w/ 2 branches and 7 members at h = 243]
## | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17206"
## | | | `--[dendrogram w/ 2 branches and 6 members at h = 239]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17033"
## | | | `--[dendrogram w/ 2 branches and 5 members at h = 236]
## | | | |--[dendrogram w/ 2 branches and 2 members at h = 232]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17304"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17270"
## | | | `--[dendrogram w/ 2 branches and 3 members at h = 236]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 231]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16234"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17276"
## | | `--[dendrogram w/ 2 branches and 11 members at h = 248]
## | | |--[dendrogram w/ 2 branches and 2 members at h = 207]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17308"
## | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17309"
## | | `--[dendrogram w/ 2 branches and 9 members at h = 245]
## | | |--[dendrogram w/ 2 branches and 6 members at h = 239]
## | | | |--[dendrogram w/ 2 branches and 2 members at h = 235]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17280"
## | | | `--[dendrogram w/ 2 branches and 4 members at h = 238]
## | | | |--[dendrogram w/ 2 branches and 2 members at h = 235]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_16219"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17211"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 236]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17007"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17256"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 242]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17242"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 234]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16242"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17306"
## | `--[dendrogram w/ 2 branches and 49 members at h = 339]
## | |--[dendrogram w/ 2 branches and 10 members at h = 294]
## | | |--[dendrogram w/ 2 branches and 5 members at h = 242]
## | | | |--[dendrogram w/ 2 branches and 3 members at h = 237]
## | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18064"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 232]
## | | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18182"
## | | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18097"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 241]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18183"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18184"
## | | `--[dendrogram w/ 2 branches and 5 members at h = 253]
## | | |--[dendrogram w/ 2 branches and 3 members at h = 231]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18165"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 228]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18166"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18174"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 239]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18172"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18191"
## | `--[dendrogram w/ 2 branches and 39 members at h = 316]
## | |--[dendrogram w/ 2 branches and 7 members at h = 272]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229"
## | | `--[dendrogram w/ 2 branches and 6 members at h = 260]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17286"
## | | `--[dendrogram w/ 2 branches and 5 members at h = 248]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17224"
## | | `--[dendrogram w/ 2 branches and 4 members at h = 244]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17260"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 238]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17155"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 235]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17314"
## | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17281"
## | `--[dendrogram w/ 2 branches and 32 members at h = 281]
## | |--[dendrogram w/ 2 branches and 22 members at h = 257]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16232"
## | | `--[dendrogram w/ 2 branches and 21 members at h = 252]
## | | |--[dendrogram w/ 2 branches and 19 members at h = 250]
## | | | |--[dendrogram w/ 2 branches and 5 members at h = 247]
## | | | | |--[dendrogram w/ 2 branches and 2 members at h = 110]
## | | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16233"
## | | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17233"
## | | | | `--[dendrogram w/ 2 branches and 3 members at h = 245]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17262"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 239]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17221"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17252"
## | | | `--[dendrogram w/ 2 branches and 14 members at h = 249]
## | | | |--[dendrogram w/ 2 branches and 4 members at h = 246]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17031"
## | | | | `--[dendrogram w/ 2 branches and 3 members at h = 245]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17254"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 243]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17024"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16228"
## | | | `--[dendrogram w/ 2 branches and 10 members at h = 247]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16236"
## | | | `--[dendrogram w/ 2 branches and 9 members at h = 245]
## | | | |--[dendrogram w/ 2 branches and 3 members at h = 242]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17268"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 239]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17327"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17316"
## | | | `--[dendrogram w/ 2 branches and 6 members at h = 244]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225"
## | | | `--[dendrogram w/ 2 branches and 5 members at h = 240]
## | | | |--[dendrogram w/ 2 branches and 3 members at h = 236]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17027"
## | | | | `--[dendrogram w/ 2 branches and 2 members at h = 234]
## | | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17294"
## | | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17272"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 237]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17313"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17279"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 251]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17026"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17153"
## | `--[dendrogram w/ 2 branches and 10 members at h = 263]
## | |--[dendrogram w/ 2 branches and 3 members at h = 247]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16247"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 238]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17230"
## | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17259"
## | `--[dendrogram w/ 2 branches and 7 members at h = 248]
## | |--[dendrogram w/ 2 branches and 3 members at h = 244]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17271"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 241]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17032"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17019"
## | `--[dendrogram w/ 2 branches and 4 members at h = 247]
## | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17257"
## | `--[dendrogram w/ 2 branches and 3 members at h = 243]
## | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17204"
## | `--[dendrogram w/ 2 branches and 2 members at h = 236]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16239"
## | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17282"
## `--[dendrogram w/ 2 branches and 77 members at h = 384]
## |--[dendrogram w/ 2 branches and 30 members at h = 320]
## | |--[dendrogram w/ 2 branches and 12 members at h = 268]
## | | |--[dendrogram w/ 2 branches and 5 members at h = 249]
## | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17238"
## | | | `--[dendrogram w/ 2 branches and 4 members at h = 245]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17287"
## | | | `--[dendrogram w/ 2 branches and 3 members at h = 241]
## | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17234"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 236]
## | | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17236"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17249"
## | | `--[dendrogram w/ 2 branches and 7 members at h = 262]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17261"
## | | `--[dendrogram w/ 2 branches and 6 members at h = 252]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17011"
## | | `--[dendrogram w/ 2 branches and 5 members at h = 242]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17219"
## | | `--[dendrogram w/ 2 branches and 4 members at h = 237]
## | | |--[dendrogram w/ 2 branches and 2 members at h = 232]
## | | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16245"
## | | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17215"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 235]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17326"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17325"
## | `--[dendrogram w/ 2 branches and 18 members at h = 277]
## | |--[dendrogram w/ 2 branches and 11 members at h = 257]
## | | |--[dendrogram w/ 2 branches and 3 members at h = 232]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18098"
## | | | `--[dendrogram w/ 2 branches and 2 members at h = 223]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18153"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18156"
## | | `--[dendrogram w/ 2 branches and 8 members at h = 243]
## | | |--leaf "Iceland_2-Offshore_Ice.Off.NE_18134"
## | | `--[dendrogram w/ 2 branches and 7 members at h = 238]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18158"
## | | `--[dendrogram w/ 2 branches and 6 members at h = 236]
## | | |--[dendrogram w/ 2 branches and 2 members at h = 233]
## | | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18080"
## | | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18095"
## | | `--[dendrogram w/ 2 branches and 4 members at h = 233]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18067"
## | | `--[dendrogram w/ 2 branches and 3 members at h = 231]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18072"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 230]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18053"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18101"
## | `--[dendrogram w/ 2 branches and 7 members at h = 261]
## | |--[dendrogram w/ 2 branches and 2 members at h = 237]
## | | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18163"
## | | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18167"
## | `--[dendrogram w/ 2 branches and 5 members at h = 242]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18085"
## | `--[dendrogram w/ 2 branches and 4 members at h = 234]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18178"
## | `--[dendrogram w/ 2 branches and 3 members at h = 234]
## | |--leaf "Iceland_2-Offshore_Ice.Off.SW_18035"
## | `--[dendrogram w/ 2 branches and 2 members at h = 231]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18069"
## | `--leaf "Iceland_1-Nearshore_Ice.Near.NE_18087"
## `--[dendrogram w/ 2 branches and 47 members at h = 356]
## |--[dendrogram w/ 2 branches and 3 members at h = 287]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18076"
## | `--[dendrogram w/ 2 branches and 2 members at h = 251]
## | |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17203"
## | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17218"
## `--[dendrogram w/ 2 branches and 44 members at h = 333]
## |--[dendrogram w/ 2 branches and 6 members at h = 262]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18168"
## | `--[dendrogram w/ 2 branches and 5 members at h = 244]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18176"
## | `--[dendrogram w/ 2 branches and 4 members at h = 233]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18073"
## | `--[dendrogram w/ 2 branches and 3 members at h = 229]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.NE_18074"
## | `--[dendrogram w/ 2 branches and 2 members at h = 224]
## | |--leaf "Iceland_1-Nearshore_Ice.Near.SW_18157"
## | `--leaf "Iceland_1-Nearshore_Ice.Near.SW_18192"
## `--[dendrogram w/ 2 branches and 38 members at h = 312]
## |--[dendrogram w/ 2 branches and 10 members at h = 259]
## | |--[dendrogram w/ 2 branches and 2 members at h = 240]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_16218"
## | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17278"
## | `--[dendrogram w/ 2 branches and 8 members at h = 248]
## | |--[dendrogram w/ 2 branches and 3 members at h = 243]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17264"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 233]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17017"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17156"
## | `--[dendrogram w/ 2 branches and 5 members at h = 245]
## | |--[dendrogram w/ 2 branches and 2 members at h = 240]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17006"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17029"
## | `--[dendrogram w/ 2 branches and 3 members at h = 243]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17296"
## | `--[dendrogram w/ 2 branches and 2 members at h = 104]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17291"
## | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16221"
## `--[dendrogram w/ 2 branches and 28 members at h = 269]
## |--[dendrogram w/ 2 branches and 5 members at h = 243]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17003"
## | `--[dendrogram w/ 2 branches and 4 members at h = 242]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17298"
## | `--[dendrogram w/ 2 branches and 3 members at h = 239]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16249"
## | `--[dendrogram w/ 2 branches and 2 members at h = 236]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17001"
## | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17277"
## `--[dendrogram w/ 2 branches and 23 members at h = 257]
## |--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17216"
## `--[dendrogram w/ 2 branches and 22 members at h = 254]
## |--[dendrogram w/ 2 branches and 2 members at h = 119]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17022"
## | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17023"
## `--[dendrogram w/ 2 branches and 20 members at h = 251]
## |--[dendrogram w/ 2 branches and 8 members at h = 244]
## | |--[dendrogram w/ 2 branches and 3 members at h = 241]
## | | |--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17267"
## | | `--[dendrogram w/ 2 branches and 2 members at h = 240]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17289"
## | | `--leaf "GoM_1-Nearshore_GoM.Cashes.Red_17263"
## | `--[dendrogram w/ 2 branches and 5 members at h = 244]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17303"
## | `--[dendrogram w/ 2 branches and 4 members at h = 241]
## | |--[dendrogram w/ 2 branches and 2 members at h = 234]
## | | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17020"
## | | `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17290"
## | `--[dendrogram w/ 2 branches and 2 members at h = 235]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_16214"
## | `--leaf "GoM_1-Nearshore_GoM.Mass.Red_17013"
## `--[dendrogram w/ 2 branches and 12 members at h = 249]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17018"
## `--[dendrogram w/ 2 branches and 11 members at h = 246]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_17030"
## `--[dendrogram w/ 2 branches and 10 members at h = 243]
## |--[dendrogram w/ 2 branches and 4 members at h = 239]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16243"
## | `--[dendrogram w/ 2 branches and 3 members at h = 237]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17154"
## | `--[dendrogram w/ 2 branches and 2 members at h = 232]
## | |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Unknown_16223"
## | `--leaf "GoM_1-Nearshore_GoM.Cashes.Olive_17235"
## `--[dendrogram w/ 2 branches and 6 members at h = 243]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224"
## `--[dendrogram w/ 2 branches and 5 members at h = 240]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17015"
## `--[dendrogram w/ 2 branches and 4 members at h = 238]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17315"
## `--[dendrogram w/ 2 branches and 3 members at h = 236]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Red_17005"
## `--[dendrogram w/ 2 branches and 2 members at h = 233]
## |--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17305"
## `--leaf "GoM_1-Nearshore_GoM.Mass.Olive.Winter_17317"
# https://www.datacamp.com/tutorial/hierarchical-clustering-R
pdf("../figures/Hclust-inversionSNPsonly.pdf", width=15, height=10)
plot(hc, cex=0.3)
rect.hclust(hc , k = 5, border=2:6)
dev.off()
## quartz_off_screen
## 2
samp_full$InvHclustOrder <- hc$order
samp_full$InvHclustK5 <- as.numeric(cut_avg)
# this looks like SW near in Iceland is more closely related to GOM then NE NEar in Iceland
table(samp_full$PopID, samp_full$InvHclustK5)
##
## 1 2 3 4 5
## GoM.Mass.Olive.Winter 22 9 2 1 0
## GoM.Mass.Red 15 17 2 1 0
## GoM.Mass.Olive.Unknown 9 5 0 3 0
## GoM.Cashes.Olive 14 5 0 6 0
## GoM.Cashes.Red 19 4 1 1 0
## Ice.Off.SW 0 0 1 1 37
## Ice.Near.SW 14 4 8 6 8
## Ice.Off.NE 0 0 0 1 38
## Ice.Near.NE 6 3 7 10 14
pdf("../figures/Hclust-inversionSNPsonly-heatmap.pdf", width=15, height=15)
par(oma=c(8,4,4,8))
heatmap(as.matrix(dist), cexRow=0.2, cexCol=0.2, scale="none", ColSideColors=samp_full$PopID_color, RowSideColors=samp_full$PopID_color, )
dev.off()
## quartz_off_screen
## 2
head(samp_full)
## samp_full Pop PopID Region Ecotype
## 1 16216 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 2 16220 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 3 16224 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 4 16225 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 5 16229 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## 6 16231 Pop1 GoM.Mass.Olive.Winter GoM 1-Nearshore
## label Region_color Ecotype_color
## 1 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216 blue4 darkcyan
## 2 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220 blue4 darkcyan
## 3 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224 blue4 darkcyan
## 4 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225 blue4 darkcyan
## 5 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229 blue4 darkcyan
## 6 GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231 blue4 darkcyan
## PopID_color Gsub_PC1 Gsub_PC2 Ecotype2 Ecotype2_color
## 1 #006400FF -0.05893059 0.027334412 1-Nearshore-GoM lightblue
## 2 #006400FF -0.06696424 0.001338206 1-Nearshore-GoM lightblue
## 3 #006400FF -0.06511353 0.002449571 1-Nearshore-GoM lightblue
## 4 #006400FF -0.06136966 0.004868653 1-Nearshore-GoM lightblue
## 5 #006400FF -0.05381484 0.015398091 1-Nearshore-GoM lightblue
## 6 #006400FF -0.05952850 0.018067312 1-Nearshore-GoM lightblue
## G_AllInv_PC1 G_AllInv_PC2 InvHclustOrder InvHclustK5
## 1 0.03531921 -0.007908553 146 1
## 2 0.06496404 -0.049032057 258 1
## 3 0.06134477 -0.053768027 230 2
## 4 0.05153129 -0.037532901 147 1
## 5 0.03185495 0.019557487 172 1
## 6 0.04147050 0.003228003 238 1
write.csv(samp_full,"../outputs/1-Samples.csv")
saveRDS(samp_full,"../outputs/1-Samples.rds")
write("This file describes information about each sample. It is saved as an RDS file for loading into R with the proper column objects (e.g. ordered factors) ",
"../outputs/1-Samples.metadata")
breakpoints
## LG LGstartIndex LGendIndex chrom LGstartPos LGendPos
## 1 LG1 33090 104012 NC_044048.1 11299038 28292263
## 2 LG2 111433 132871 NC_044049.1 481246 4466546
## 3 LG7 648745 696592 NC_044054.1 16828712 26336501
## 4 LG12 1098771 1141346 NC_044059.1 1809214 13690550
## LGstartPos_minus1MB_index LGendPos_plus1MB_index
## 1 29750 106154
## 2 109720 135332
## 3 645345 700639
## 4 1096496 1142816
write.csv(breakpoints, "../outputs/1-breakpoints.csv", row.names = FALSE)
write("This file describes the breakpoint of inversions identified by the 99% outlier PCA loadings for individual chromsome /n
LG: linkage group /n
LGstartIndex: Start index of the inversion in the full genotype matrix stored in `1-AllGSNPs.rds` /n
LGendIndex: end index of the inversion in the full genotype matrix stored in `1-AllGSNPs.rds` /n
chrom: chromosome /n
LGstartPos: start position of the inversion on the chromosoms /n
LGendPos: end start position of the inversion on the chromosoms /n
LGstartPos_minus1MB_index: Start index minus 1 MB of the inversion in the full genotype matrix stored in `1-AllGSNPs.rds` /n
LGendPos_plus1MB_index: end index plus 1MB of the inversion in the full genotype matrix stored in `1-AllGSNPs.rds` /n",
"../outputs/1-breakpoints.csv.metadata.md")
head(G_full[,1:5]) # make sure rows and columns are labeled
## NC_044048.1__268 NC_044048.1__280
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216 0 2
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220 1 2
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224 1 2
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225 0 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229 1 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231 1 1
## NC_044048.1__378 NC_044048.1__539
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216 0 1
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220 0 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224 0 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225 0 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229 0 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231 0 0
## NC_044048.1__1555
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16216 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16220 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16224 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16225 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16229 0
## GoM_1-Nearshore_GoM.Mass.Olive.Winter_16231 0
saveRDS(G_LG, "../outputs/1-AllLGSNPs.rds")
dim(G_LG)
## [1] 294 182786
write("This file is a genotype matrix for SNPs located in the four inversions
Each matrix has individuals in rows and SNPs in columns
Each cell has the number of copies of the alternate allele",
"../outputs/1-AllLGSNPs.metadata.md")
saveRDS(G_full[,LG1start_minus1MB:LG1end_plus1MB], "../outputs/1-G_LG1.rds")
saveRDS(G_full[,LG2start_minus1MB:LG2end_plus1MB], "../outputs/1-G_LG2.rds")
saveRDS(G_full[,LG7start_minus1MB:LG7end_plus1MB], "../outputs/1-G_LG7.rds")
saveRDS(G_full[,LG12start_minus1MB:LG12end_plus1MB], "../outputs/1-G_LG12.rds")
write("These files are genotype matrices for the inversions on each linkage group
Each matrix has individuals in rows and SNPs in columns
Each cell has the number of copies of the alternate allele",
"../outputs/1-G_LGX.metadata.md")